package com.laikan.reader.bookfriend.net;

import com.laikan.library.httpvolley.helper.VolleyErrorHandler;
import com.laikan.library.httpvolley.response.HttpResponse;
import com.laikan.reader.bookfriend.base.IView;

/**
 * Created by lingyt on 2016/11/15.
 * 简化了回调
 */
public abstract class SimpleCallback<T> extends BaseCallback<T>{

    private IView mIView;

    public SimpleCallback(IView iView) {
        super();
        mIView = iView;
    }

    @Override
    public void onPreExecute() {
        if (mIView != null) {
            mIView.showProgress();
        }
    }

    @Override
    public abstract void onSuccess(HttpResponse httpResponse, T t);

    @Override
    public abstract void onError(VolleyErrorHandler errorHandler);

    @Override
    public void onFinish() {
        if(mIView != null){
            mIView.hideProgress();
        }
    }
}
